<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <p>11</p>
    <p style="display: none;">22</p>
    <p>333</p>

    <script>

        // jq本质就是一个构造函数
        // $是实例化的过程


        function Get(el) {
            this.el = document.querySelectorAll(el);
        }

        Get.prototype.hide = function () {
            for (let i = 0; i < this.el.length; i++) {
                this.el[i].style.display = 'none';
            }
        }

        Get.prototype.show = function () {
            for (let i = 0; i < this.el.length; i++) {
                this.el[i].style.display = 'block';
            }
        }


        Get.prototype.toggle = function () {
            for (let i = 0; i < this.el.length; i++) {
                // this.el[i].style.display = 'block';
                if (this.el[i].style.display === 'none') {
                    this.el[i].style.display = 'block';
                }
                else {
                    this.el[i].style.display = 'none';
                }
            }
        }



        function $(el) {
            return new Get(el);
        }



        // $('p').hide()

        // setTimeout(() => {
        //     $('p').show()
        // }, 1000)

        $('p').toggle()

    </script>

</body>

</html>